<template>
  <div class="w-full h-50px" ref="chartRef"></div>
</template>

<script lang="ts">
  import { defineComponent } from 'vue';

  export default defineComponent({
    name: 'BarChart',
  });
</script>

<script lang="ts" setup>
  import { ref, onMounted } from 'vue';
  import * as echarts from 'echarts';

  const chartRef = ref();

  onMounted(() => {
    const chart = echarts.init(chartRef.value);

    const option = {
      xAxis: {
        show: false,
        data: [
          '一月',
          '二月',
          '三月',
          '四月',
          '五月',
          '六月',
          '七月',
          '八月',
          '九月',
          '十月',
          '十一月',
          '十二月',
        ],
      },
      yAxis: {
        show: false, // 隐藏坐标轴
      },
      series: {
        type: 'bar',
        data: [20, 30, 11, 24, 20, 30, 14, 24, 20, 30, 12, 24],
      },
      grid: {
        left: 0,
        right: 0,
        top: 0,
        bottom: 0,
      },
    };

    chart.setOption(option);
  });
</script>
